<template>
  <div class="father">
    <div class="imgBox">

      <!--        <img v-for="(item,index) in imgUrl" :src="item" alt="" :key="index" ref="img">-->
      <el-carousel :interval="5000" arrow="always" style="height: 406px;">
        <el-carousel-item v-for="(item,index) in imgUrl" :key="index" style="height: 406px;">
          <img :src="item.imgUrl" :title="item.title" :alt="item.description" @click="RotationClick(item)">
        </el-carousel-item>
        <!--                <el-carousel-item style="height: 406px;">-->
        <!--                  <img src="@/assets/index_images/rotation1.jpg" alt="">-->
        <!--                </el-carousel-item>-->
        <!--        <el-carousel-item style="height: 406px;">-->
        <!--          <img src="@/assets/index_images/rotation2.jpg" alt="">-->
        <!--        </el-carousel-item>-->
        <!--        <el-carousel-item style="height: 406px;">-->
        <!--          <img src="@/assets/index_images/rotation3.jpg" alt="">-->
        <!--        </el-carousel-item>-->
      </el-carousel>
    </div>
  </div>
</template>

<script>
export default {
  name: "Rotation",
  data() {
    return {
      bookQuery: {
        pageSize: null,
        sort: 'recommand'
      },
      // index:0,
      // len:0,
      imgUrl: [],

    }
  },
  methods: {
    RotationClick(item) {
      if (item.type === 1)
        this.$router.push({path: '/articleDetail', query: {id: item.aid}})
      else
        this.$router.push({path: '/purchasePage', query: {curBookId: item.bid}})
    }

  },
  mounted() {
    // setInterval(this.slideShow,3000)

  },
  created() {
    // this.getRequest('/p/pms/book/customList',)
    this.getRequest('/p/ims/swiper/list2').then((resp) => {
      this.imgUrl = resp.data
    })
  }
}
</script>

<style scoped>
/*轮播图*/
.father {
  position: relative;
}

.imgBox {
  /*border-top: 5px solid cadetblue;*/
  width: 66%;
  height: 40%;
  margin: 0 auto;
  /*border: solid 1px red;*/
  position: absolute;
  left: 22em;
  top: -27em;
}

.imgBox img {
  width: 765px;
  height: 406px;
  /*height: 40px;*/
  margin: 0 auto;
  /*display: none;*/
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 18px;
  opacity: 0.75;
  line-height: 300px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}
</style>